<template>

  <el-dialog
    title="提示"
    :visible.sync="centerDialogVisible"
    width="60%"
    center
  >
    <el-form v-model="dataFrom">
      <el-form-item label="姓名">
        <el-input v-model="dataFrom.name" />
      </el-form-item>
      <el-form-item label="用户名">
        <el-input v-model="dataFrom.userName" />
      </el-form-item>
      <el-form-item label="年龄">
        <el-input-number v-model="dataFrom.age" />
      </el-form-item>
      <el-form-item label="性别">
        <el-input v-model="dataFrom.sex" />
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="centerDialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="addUserInfo">提 交</el-button>
    </span>
  </el-dialog>
</template>
<script>
import { addUser } from '@/api/myuser'
export default {
  data() {
    return {
      centerDialogVisible: false,
      dataFrom: {
        name: undefined,
        userName: undefined,
        age: 0,
        sex: undefined
      }
    }
  },
  methods: {
    init() {
      this.centerDialogVisible = true
    },
    addUserInfo() {
      addUser(this.dataFrom).then(rsp => {
        this.centerDialogVisible = false
      })
    }
  }
}

</script>

<style scoped>

</style>
